Printing using InvokeVerbEx("Print")

This is Vb.NET forum which is different from vbscript, try to repost your question in VBscript forum for better responses at  http://social.technet.microsoft.com/Forums/en-US/ITCG/threads

kaymaf

July 18th, 2011 1:17pm

Hi all,

I'm using InvokeVerbEx("Print") to print files. After banging my face on my keyboard for a full half an hour my script now works like a charm, printing all the files with specific extensions in in a specified folder and subfolders recursively. Except for one really annoying thing:

Among the files are JPEG images. Passing these to InvokeVerbEx("Print") causes the Photo Printing Wizard to pop up, as I believe the function is basically equal to right-clicking a file and selecting Print. Is there any way to bypass the wizard and just have them sent to the printer, like -s on a software install?

Many thanks,

Free Windows Admin Tool Kit Click here and download it now
July 18th, 2011 7:37pm

There is no default renderer for jpg images.  Set one with a print command and you will get it.

I don't believe IE as a default will wotk and I don't think paint will work.  Check the print key.

 

July 18th, 2011 7:59pm

I thought of that, but unfortunately I work for a rather large company with an extremely fussy IT policy and I cannot have any server settings changed without putting forward a 'business case'. You see we connect through Terminal Services and any change made to that server affects all users. I suspect most people find the wizard helpful.

Is there a function other than InvokeVerbEx("Print") that I can use? Can I call an API?

Free Windows Admin Tool Kit Click here and download it now
July 18th, 2011 8:10pm

Who said anything about servers. It is the account you are printing from that has complete control over that,

What? Did Microsoft stop teaching Desktop Supoprt or did you immediately dorget everything after you took the exam?

 

The session youa re in renders the content to the print spooler using teh aplpicationa nd teh printer driver user component.  As and example: Microsoft Word knows how to sen a Word document to a print device by making the device calls to set  up a print job a converty the content into an image or into text.  MSWord docs are images(DIB - Device INdependent Bitmap) these can be rendered by all matrix printers.

A JPEG needs a program that knows how to convert a JPEG into a DIB.  IE can do this. Word can do this , Paint can do this and Windows Picture & Fax Viewer can do this. This is the dialog you are seeing.  It is because the file extension is associated with this program.  P&FManager can be called with automation and teh args for the Wizard can be bypassed.

You can also use a differnt program to do the printing by specifying the program, the file and the command. I believe you can do this with word. I am not sure about JPEG files.

I just checked and it appears that 'print' knows how to call P&F with a print command

PRINT [/D:device] [[drive:][path]filename[...]]

   /D:device   Specifies a print device.

 

July 18th, 2011 8:46pm

Well that was harsh! But as it is constructive criticism and you are being very helpful I will not take offence.

We connect from desktop computers running XP to a server running Server 2003 via Terminal Services. The server renders the print job and spools it to the default printer on the XP machine via the TS connection. So it is the default for JPEGs on the server that matters - my local machine just provides the printer.

I do understand how rendering and printing works, the issue is with the language. With C#, as long as I have an API or library that provides the functionality and I know how to reference it, I can print whatever I like. To be honest, I would prefer to use DLLs and interop for this rather than InvokeVerbEx("Print") for this. Programs loading and closing reduces the efficiency drastically and requires human intervention.

Is there a way I can do this, or is the language simply incapable?

Free Windows Admin Tool Kit Click here and download it now
July 18th, 2011 9:05pm

I am not hazing you.

I am just wondering why you think this is necessary.  UYpi don't need INterop or any of theose other things to print.  When a user send a file to a printer teh local session renders the  output. It has nbothing to do wqih C# or Interop or Invoking of verbs.  Yu can use the DOS print command and it wil always choose the correct renderer if it is installed.

In you case the renderer is P & F viewer which ahs no defult besides the Wizard. Form a command line yuo can type "rundll PFWiz.dll,print", filename and it should print.  It will still display the wizard. There is a runtime commsnd that will tell it not to display the wizard.

When you use InvodeVerb to print you are just opening a dicument withteh default engine and sending a DDE command 'print'.  This is what ahppens with a JPEG abd P&F displays teh wizard.  Change the defualt rendering engine and you will not get this.  Find the correct verb and subcommand and you will skip this dialog.

 

 

July 18th, 2011 9:53pm

Excellent! Thank you very much jv. I will post my code once I have completed it, as it might help others.
Free Windows Admin Tool Kit Click here and download it now
July 18th, 2011 9:57pm

Excellent! Thank you very much jv. I will post my code once I have completed it, as it might he
July 18th, 2011 10:07pm

Hi James,

Welcome to the MSDN Forum.

I agree with Kaymaf. I moved this thread to the more appropriate forum for better support.

Best regards,

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2011 8:17am

There is no INvokVerbEx in vbscript.  It is a VB only command.

Te default print program in Windows is Printing & Fax Wizard.  You need to use a different progra, as the Wizard will alway pop up with teis program.

YOu can try this a a command lie an dsee how it worls.

rundll32 c:\windows\system32\shimgvw.dll,ImageView_PrintTo /pt "c:\scripts\sec.jpg" "HP Laserjet 5"

This will cause teh image to be printed without any wizard.  I t will print using all defaults for that image type.

 YOu canalso use MSPAINT to print to the default printer.

mspaint /pt c:\scripts\sec.jpg

 

 

 

July 20th, 2011 1:47pm

There is no INvokVerbEx in vbscript.  It is a VB only command.

Te default print program in Windows is Printing & Fax Wizard.  You need to use a different progra, as the Wizard will alway pop up with teis program.

YOu can try this a a command lie an dsee how it worls.

rundll32 c:\windows\system32\shimgvw.dll,ImageView_PrintTo /pt "c:\scripts\sec.jpg" "HP Laserjet 5"

This will cause teh image to be printed without any wizard.  I t will print using all defaults for that image type.

 YOu canalso use MSPAINT to print to the default printer.

mspaint /pt c:\scripts\sec.jpg

 

 

 

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2011 1:12pm

Hi! Im waking this thread back to life.

I need to create a scheduled task for windows 7 which prints everyday one .jpg file out of my big printer. It needs to be used everyday or else it will brake itself.

So what I need is a command to cmd what I am going to use inside .bat file and schedule that to be printed everyday.

Printer what I'm using is a web printer and I was not succesfull of using next command:

rundll32 c:\windows\system32\shimgvw.dll,ImageView_PrintTo /pt D:\maisema.jpg /D:\\printer.web.address\printer.web.name

Any ideas how to proceed?


  • Edited by MrMuscle 18 hours 53 minutes ago
August 3rd, 2015 8:19am

Thread is closed and has been for along time. Please start you own thread.

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 11:47am

Hi! Im waking this thread back to life.

I need to create a scheduled task for windows 7 which prints everyday one .jpg file out of my big printer. It needs to be used everyday or else it will brake itself.

So what I need is a command to cmd what I am going to use inside .bat file and schedule that to be printed everyday.

Printer what I'm using is a web printer and I was not succesfull of using next command:

rundll32 c:\windows\system32\shimgvw.dll,ImageView_PrintTo /pt D:\maisema.jpg /D:\\printer.web.address\printer.web.name

Any ideas how to proceed?


  • Edited by MrMuscle Monday, August 03, 2015 12:17 PM
August 3rd, 2015 12:16pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics